{% extends 'layout.html' %}

{#title#}
{% block title %}
    <title>员工主页</title>
{% endblock %}


{#content#}
{% block content %}
    <a href="{% url 'emp_add' %}">
        <button class=" btn btn-primary btn-sm" style="margin-bottom: 10px">新增</button>
    </a>
    <div class="panel panel-default">
        <!-- Default panel contents -->
        <div class="panel-heading">员工列表</div>
        <!-- Table -->
        <table class="table table-hover table-bordered">
            <tr>
                <th>序号</th>
                <th>工号</th>
                <th>姓名</th>
                <th>年龄</th>
                <th>薪资</th>
                <th>入职时间</th>
                <th>部门</th>
                <th>操作</th>
            </tr>
            {% for emp in table_data %}
                <tr>
                    <td>{{ forloop.counter }}</td>
                    <td>{{ emp.eno }}</td>
                    <td>{{ emp.name }}</td>
                    <td>{{ emp.age }}</td>
                    <td>{{ emp.salary }}</td>
                    <td>{{ emp.hire_date }}</td>
                    <td>{{ emp.department.name }}</td>
                    <td>
                        <a href="{% url 'emp_edit' emp.id %}">
                            <button class=" btn btn-primary btn-sm">编辑</button>
                        </a>
                        <a href="{% url 'emp_delete' emp.id %}">
                            <button class=" btn btn-danger btn-sm">删除</button>
                        </a>
                    </td>
                </tr>
            {% endfor %}
        </table>
    </div>
    <div style="text-align: center;position: relative;top: -25px;">
        {#    分页器#}
        <nav aria-label="Page navigation">
            <ul class="pagination">
                <li>
                    <a href="#">总条数:{{ total_count }}</a>
                </li>
                {% if has_previous %}
                    <li>
                        <a href="{% url 'emp_list' %}?page={{ pre_page }}" aria-label="Previous">
                            <span aria-hidden="true">&laquo;</span>
                        </a>
                    </li>
                {% endif %}
                {% for num in page_range %}
                    <li {% if current_page_number == num %}class="active" {% endif %}><a
                            href="{% url 'emp_list' %}?page={{ num }}">{{ num }}</a></li>
                {% endfor %}
                {% if has_next %}
                    <li>
                        <a href="{% url 'emp_list' %}?page={{ next_page }}" aria-label="Next">
                            <span aria-hidden="true">&raquo;</span>
                        </a>
                    </li>
                {% endif %}
                <li>
                    <a href="#">总页数:{{ total_pages }}</a>
                </li>
            </ul>
        </nav>
    </div>
{% endblock %}